package com.sanyang.lawyer.controller.Statistics;

import com.sanyang.lawyer.entity.Case_type;
import com.sanyang.lawyer.entity.HrFlexigrid;
import com.sanyang.lawyer.service.Case.Case_lawService;
import com.sanyang.lawyer.service.Case.Case_typeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: lawyer
 * @description: 收结案统计控制层
 * @author: Mis.Feng
 * @create: 2019-10-31 09:35
 **/
@RestController
@RequestMapping("cStatistics")
public class ClosingStatisticsController {
    @Autowired
    private Case_lawService cls;
    @Autowired
    private Case_typeService cts;

    @RequestMapping("ClosingStatistics")
    public Map<String,Object> ClosingStatistics(HttpServletRequest request){
        Map map1 = initMap(request);
        HrFlexigrid hrFlexigrid=new HrFlexigrid(map1,request);
        map1.put("Flexigrid",hrFlexigrid);
        List<Map<String, Object>> list = cls.StatisticsList(map1);
        Integer i = cls.StatisticsListCount(map1);
        Map map=new HashMap();
        map.put("code", 0);
        map.put("msg", "");
        map.put("count", i);
        map.put("data", list);
        return map;
    }

    @RequestMapping("businessCharge")
    public Map<String,Object> businessCharge(HttpServletRequest request){
        Map map1 = initMap(request);
        HrFlexigrid hrFlexigrid=new HrFlexigrid(map1,request);
        map1.put("Flexigrid",hrFlexigrid);
        System.out.println(map1);
        List<Map<String, Object>> list = cls.businessCharge(map1);
        Integer i = cls.businessChargeCount(map1);
        Map map=new HashMap();
        map.put("code", 0);
        map.put("msg", "");
        map.put("count", i);
        map.put("data", list);
        return map;
    }

    @RequestMapping("personalBusiness")
    public Map<String,Object> personalBusiness(HttpServletRequest request){
        Map map1 = initMap(request);
        HrFlexigrid hrFlexigrid=new HrFlexigrid(map1,request);
        map1.put("Flexigrid",hrFlexigrid);
        List<Map<String, Object>> list = cls.personalBusiness(map1);
        Integer i = cls.personalBusinessCount(map1);
        System.out.println("iiiiiiiiiiiiii"+i);
        Map map=new HashMap();
        map.put("code", 0);
        map.put("msg", "");
        map.put("count", i);
        map.put("data", list);
        return map;
    }
    @RequestMapping("listByid")
    public List<Case_type> listBypid(){
        List<Case_type> list = cts.listByid();
        return list;
    }

    @RequestMapping("legalCounsel")
    public Map<String,Object> legalCounsel(HttpServletRequest request){
        Map map1 = initMap(request);
        HrFlexigrid hrFlexigrid=new HrFlexigrid(map1,request);
        map1.put("Flexigrid",hrFlexigrid);
        List<Map<String, Object>> list = cls.legalCounsel(map1);
        Integer i = cls.legalCounselCount(map1);
        Map map=new HashMap();
        map.put("code", 0);
        map.put("msg", "");
        map.put("count", i);
        map.put("data", list);
        return map;
    }

    public Map<String, Object> initMap(HttpServletRequest request) {
        String empId=request.getParameter("empId");
        String courtId=request.getParameter("courtId");
        String starttime=request.getParameter("starttime");
        String endtime=request.getParameter("endtime");
        String payId=request.getParameter("payId");
        String caseType=request.getParameter("caseType");
        Map<String, Object> map = new HashMap();
        map.put("empId",empId);
        map.put("courtId",courtId);
        map.put("starttime",starttime);
        map.put("endtime",endtime);
        map.put("payId",payId);
        map.put("caseType",caseType);
        return map;
    }
}
